package com.itheima.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
//@Aspect
public class AspectDemo1 {
    @Pointcut("@annotation(com.itheima.anno.Flag)")
    public void pt(){}

    @Around("pt()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
//       获取类名
        String className = pjp.getTarget().getClass().getName();
//        获取方法名
        String methodName = pjp.getSignature().getName();
//        获取方法形参
//        Object[] args = pjp.getArgs();
        System.out.println(className+"."+methodName+"()方法开始执行");
        Object result = pjp.proceed();
        System.out.println(result);
        return result;
    }
}
